/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.tom.social.common.jade;

import jade.core.AID;
import jade.core.Agent;
import jade.lang.acl.ACLMessage;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 *
 * @author Tom
 */
public class TaskBarProxy {
	private static final Logger logger = Logger.getLogger(TaskBarProxy.class);
	private Agent parent;
	private AID receiver;

	public TaskBarProxy(Agent parent, AID receiver) {
		this.parent = parent;
		this.receiver = receiver;
	}

	public void update(String info) {
		ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
		msg.addReceiver(receiver);
		msg.setContent(info);
		parent.send(msg);
		logger.log(Level.DEBUG, "Task update requested for " + receiver.getName() + " with task " + info);
	}

	public void finish() {
		ACLMessage msg = new ACLMessage(ACLMessage.CANCEL);
		msg.addReceiver(receiver);
		parent.send(msg);
		logger.log(Level.DEBUG, "Task finished for " + receiver.getName());
	}
}
